<!--
 * @Author: scopesang
 * @Date: 2022-04-07 15:45:00
 * @LastEditors: scopesang
 * @LastEditTime: 2022-04-07 16:24:16
 * @FilePath: \cms-manage\test\class.html
 * @Description: 
 * 
 * Copyright (c) 2022 by scopesang/大鹏科技, All Rights Reserved. 
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
</html>

<script type="text/javascript">
  // 构造函数
  //     function Animal(vname){
  //     this.name = vname;
  //     this.sayInfo = function(){
  //         console.log('这是一只'+this.name)
  //     }
  // }

  // function Dog(vname){
  //     this.anme = "sdfjslkdfjlsddkjf"
  //     Animal.call(this,this.anme)
  // }

  // var dog = new Dog('狗狗');
  // dog.sayInfo();	// 这是一只狗狗

  // 面向对象  类

  class Animal {
    // 构造器
    constructor(vname) {
      this.name = Animal
    }
    sayInfo() {
      console.log('这是一只' + this.name)
    }
  }

  class Dog extends Animal {
    constructor(props) {
      // 超类，接收父类传递过来的属性
      super(props)
    }
  }

  let dog = new Dog('狗狗')
  dog.sayInfo()
</script>
